/** @format */

import permission from "_libs/permission"
export default {
	inserted(el, binding, vnode) {
		const { value } = binding
		if (value && value instanceof Array && value.length > 0) {
			const hasPermission = permission.hasPermission(value[0])
			if (!hasPermission) {
				console.warn("当前页面的按钮元素因为没有找到包含的key已被删除", value[0])
				el.parentNode && el.parentNode.removeChild(el)
			}
		} else {
			throw new Error(`need roles! Like v-permission="['key']"`)
		}
	}
}
